package org.shopen.puremvc.controller.notehandlers
{
	import mx.collections.ArrayCollection;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	import org.puremvc.as3.utilities.statemachine.StateMachine;
	import org.shopen.puremvc.ApplicationConstants;
	import org.shopen.puremvc.model.ConfigProxy;
	import org.shopen.puremvc.model.ProjectProxy;
	import org.shopen.puremvc.model.vo.ProjectInfo;
	import org.shopen.puremvc.model.vo.SaveInfo;

	public class HandleSavingRequestCommand extends SimpleCommand
	{
		override public function execute(notification:INotification):void
		{
			try
			{
				var projectProxy : ProjectProxy = facade.retrieveProxy(ProjectProxy.NAME) as ProjectProxy;
				var project : ProjectInfo = projectProxy.project;
				
				var configProxy : ConfigProxy = facade.retrieveProxy(ConfigProxy.NAME) as ConfigProxy;
				var filetypes : ArrayCollection = configProxy.getFileTypes();
				
				var saveInfo : SaveInfo = new SaveInfo(project.name, filetypes);
				sendNotification(StateMachine.ACTION, saveInfo, ApplicationConstants.ACTION_REQUEST_SAVING);
			}
			catch(error : Error)
			{
				sendNotification(ApplicationConstants.GENERAL_ERROR, error);
			}
		}
	}
}